<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/2/12
 * Time: 11:33 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.multiselect');
JHtml::_('behavior.mootools');

$document = JFactory::getDocument();

$script=<<<AUTOCOMPLETE
    window.addEvent('domready', function() {
        document.formvalidator.setHandler('tendonvi',
            function (value) {
                regex=/^(\w*)(\s*)(.*){1,128}$/;
                if (!regex.test(value))
                    alert('Giá trị tên đơn vị không hợp lệ phải có tối thiểu 1 chữ cái và tối đa 128 chữ cái');
                return regex.test(value);
            });
    });
AUTOCOMPLETE;

$document->addScriptDeclaration($script);

$item = $this->get('item');
$khoi = $this->get('khoi');
$hosocanbo = VastHelper::getHosocanbo();
$donvi = VastHelper::getDonViLanhDao();
if (!JFactory::getUser()->authorise('vast.donvi.edit', 'com_vast') && !(JFactory::getUser()->authorise('vast.donvi.edit.own', 'com_vast') && $donvi !== NULL && $donvi->donviid == $item['id']))
{
    JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_vast&view=vast'));                    
}

?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <?php if (isset($khoi)): ?>        
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=donvitructhuoc&id=' . $khoi->id); ?>"><?php echo $khoi->ten ?></a> »                
        <?php endif; ?>
        <span>Cập nhật thông tin cho đơn vị</span>
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">Cập nhật thông tin cho đơn vị <?php echo $item['ten']; ?></h3>
    
    <div class="form">
        <form class="commentform form-validate" action="<?php echo JRoute::_('index.php?option=com_vast&view=donvi&layout=edit&id=' . $item['id']); ?>" method="post" id="donvi" name="adminForm">
            
            <div class="row">
                <?php echo $this->form->getLabel('id'); ?>
                <?php echo $this->form->getInput('id'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('khoi_id'); ?>
                <?php echo $this->form->getInput('khoi_id'); ?>
            </div>
                    
            <div class="row">
                <?php echo $this->form->getLabel('ten'); ?>
                <?php echo $this->form->getInput('ten'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('hinhanh'); ?>
                <?php echo $this->form->getInput('hinhanh'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('diachi'); ?>
                <?php echo $this->form->getInput('diachi'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('sodienthoai'); ?>
                <?php echo $this->form->getInput('sodienthoai'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('fax'); ?>
                <?php echo $this->form->getInput('fax'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('thudientu'); ?>
                <?php echo $this->form->getInput('thudientu'); ?>
            </div>
 
            <div class="row">
                <?php echo $this->form->getLabel('website'); ?>
                <?php echo $this->form->getInput('website'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('hoidongkhoahoc'); ?>
                <?php echo $this->form->getInput('hoidongkhoahoc'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('chucnang'); ?>
                <?php echo $this->form->getInput('chucnang'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('nhiemvu'); ?>
                <?php echo $this->form->getInput('nhiemvu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('hoatdongthuongxuyen'); ?>
                <?php echo $this->form->getInput('hoatdongthuongxuyen'); ?>
            </div>
 
            <div class="row">
                <?php echo $this->form->getLabel('thanhtuu'); ?>
                <?php echo $this->form->getInput('thanhtuu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('thongtinkhac'); ?>
                <?php echo $this->form->getInput('thongtinkhac'); ?>
            </div>
            <div class="row">
                <input type="hidden" name="option" value="com_vast" />
                <input type="hidden" name="task" value="donvi.update" />
            </div>
            
            <div class="row buttons">
                <button type="submit" class="button validate" id="submit"><?php echo JText::_('Cập nhật'); ?></button>
                <?php echo JHtml::_('form.token'); ?>
            </div>
        </form>
    </div>
</div>